package com.kexin.jbsg.feiliu;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import com.fl.gamehelper.base.info.UserInfo;
import com.fl.gamehelper.service.FlGameSdkMSg;

public class FlGameSdkMSgReceiver extends BroadcastReceiver {

	public FlGameSdkMSgReceiver() {
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		if (intent.getAction().equals(FlGameSdkMSg.PLAY_GAME_ACTION)) {
			String _msg = intent.getStringExtra(FlGameSdkMSg.MSG_TAG);
			if (_msg.equals(FlGameSdkMSg.MSG_TO_GAME_MAIN_SCREEN)) {
				Toast.makeText(context,"成功登录", Toast.LENGTH_SHORT).show();
				// 取用户的唯一标识 uuid
				UserInfo _u = UserInfo.getUserInfo(context);
				String uuid = _u.getmUUid();
				// 取开放平台用户的token,非第三方平台无token
				int accountType = _u.getmAccountType();
				String token = "";
				switch (accountType) {
				case 2:
					token = _u.getmToken();
					break;
				case 6:
					token = _u.getmToken();
					break;
				}		
				//启动游戏
				String message = uuid+","+_u.getmSign()+","+_u.getmTimeStamp();
				MainActivity.instance.sendLoginSuccessMessage(message);
				
			}else if(_msg.equals(FlGameSdkMSg.MSG_EXIT_LOGIN)){
				//退出游戏
				MainActivity.exitGameFL();
			}
		}

	}
}
